package com.invest.utils.type;

import com.google.common.collect.Maps;
import org.apache.commons.lang.StringUtils;

import java.util.Map;

/**
 * Created by evan on 2016/6/14.
 */
public enum MessageStatusType {
    I("初始化"),
    P("处理中"),
    S("成功"),
    F("失败");

    private String message;
    private MessageStatusType(String message){
        this.message=message;
    }

    private static Map<String,MessageStatusType> INSTANCE_MAP = Maps.newHashMap();
    private static  Map<String,String> MSG_MAP = Maps.newLinkedHashMap();
    static{
        for(MessageStatusType type : values()){
            INSTANCE_MAP.put(type.name(),type);
            MSG_MAP.put(type.name(),type.message);
        }
    }
    public static Map<String,String> getMsgMap(){
        return MSG_MAP;
    }

    public static MessageStatusType instanceByName(String name){
        if(StringUtils.isBlank(name)){
            return null;
        }
        return INSTANCE_MAP.get(name);
    }

}
